#ifndef TILE_SHEET_H
#define TILE_SHEET_H

#include <QObject>
#include <QList>
#include <QMap>
#include <QPair>
#include <QPixmap>
#include <QString>

class PackMetadata;
class QPixmap;
class Tile;

class TileSheet : public QObject {
  Q_OBJECT
  Q_PROPERTY(QString name READ name)
  Q_PROPERTY(int rows READ rows)
  Q_PROPERTY(int columns READ columns)
  Q_PROPERTY(QSize tileSize READ tileSize)

 public:
  explicit TileSheet(QString name,
                     const QPixmap& pixmap,
                     int rows,
                     int columns,
                     const PackMetadata* metadata,
                     QObject* parent = NULL);
  QList<Tile*> allTiles();
  QString name() const;
  int rows() const;
  int columns() const;
  QSize tileSize() const;
  Tile* tile(int row, int col);
  const QPixmap& pixmap() const;

 private:
  QString name_;
  QPixmap pixmap_;
  int rows_;
  int columns_;
  const PackMetadata* pack_metadata_;
  QMap< QPair<int, int>, Tile*> tile_cache_;
};

QDebug& operator<<(QDebug debug, const TileSheet& sheet);

#endif // TILE_SHEET_H
